package com.hp.attendance.serlvet.empmanage.zaizhi;

import com.hp.attendance.service.EmployeeService;
import com.hp.attendance.service.HistoryService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

@WebServlet("/historyZZDelete")
public class EmpManageZZHistoryDeleteServlet extends HttpServlet {
    private HistoryService historyService = new HistoryService();
    private EmployeeService employeeService = new EmployeeService();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        try {
            int employee_number = Integer.parseInt(req.getParameter("employee_number"));
            int id = Integer.parseInt(req.getParameter("id"));
            employeeService.empDelete(id);
            historyService.hisDelete(employee_number);
            req.getRequestDispatcher("/empMangeZZList").forward(req,resp);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
